CalendarService = Packages.com.google.gdata.client.calendar.CalendarService;
gdata           = Packages.com.google.gdata.data;
CalendarEntry   = Packages.com.google.gdata.data.calendar.CalendarEntry;
PlainTextConstruct = Packages.com.google.gdata.data.PlainTextConstruct;
TimeZoneProperty   = Packages.com.google.gdata.data.calendar.TimeZoneProperty;
HiddenProperty     = Packages.com.google.gdata.data.calendar.HiddenProperty;
ColorProperty      = Packages.com.google.gdata.data.calendar.ColorProperty;
Where              = Packages.com.google.gdata.data.extensions.Where;
CalendarService = Packages.com.google.gdata.client.calendar.CalendarService;
gdata           = Packages.com.google.gdata.data;
AclEntry        = Packages.com.google.gdata.data.acl.AclEntry;
AclScope        = Packages.com.google.gdata.data.acl.AclScope
CalendarAclRole = Packages.com.google.gdata.data.calendar.CalendarAclRole
CalendarFeed    = Packages.com.google.gdata.data.calendar.CalendarFeed;
SelectedProperty= Packages.com.google.gdata.data.calendar.SelectedProperty
  
function main( ui ) {

              var json = ui.getFirst("json");
              if ( json == null ){
                var ex = "{ exception: { message: 'no param provided'} }";
                return ex;
              }
           try{
              var jsonObject = new JSONObject( json );
              var service = new CalendarService("demo-calendar-1");
              var username = "soulsoftware2010@gmail.com";
              var password = "2010soulsoftware";
               
              var idCalendar=jsonObject.get("IDCALENDAR");
              var timezone=jsonObject.get("TIMEZONE");
             
              service.setUserCredentials(username, password);

              var feedUrl = new java.net.URL("https://www.google.com/calendar/feeds/default/allcalendars/full");
              var resultFeed = service.getFeed(feedUrl, CalendarFeed);
      
              for (var i = 0; i < resultFeed.getEntries().size(); i++) {
                 var entry = resultFeed.getEntries().get(i);
                 if (entry.getTitle().getPlainText().equals(idCalendar)){
                     var timeZone = new TimeZoneProperty();
                     timeZone.setValue(timezone);
                     entry.setTimeZone(timeZone);
                     entry.setSelected(SelectedProperty.TRUE);
                     entry.update();
                     break;
               }
            }
         }catch( e ) {
             return e;
         }
         return "{result:'OK'}";
}